# Maintainer: David Sugar <tychosoft@gmail.com>
# Contributor: David Sugar <tychosoft@gmail.com>
pkgname=bordeaux
pkgver=0.8.1
pkgrel=0
pkgdesc="SIP telephony application server"
url="https://www.tychosoft.com/tychosoft/bordeaux/wiki"
arch="all"
license="GPL-3.0-or-later"
makedepends="cmake fmt-dev>=8.1.0 flite-dev openssl-dev moderncli-dev>=0.8.0 libosip2-dev>=5.3.0 libexosip2-dev>=5.3.0 rapidjson-dev"
subpackages="$pkgname-doc $pkgname-openrc $pkgname-dev $pkgname-coventry $pkgname-generic $pkgname-en_voices"
source="https://www.tychosoft.com/api/packages/tychosoft/generic/bordeaux/$pkgver/bordeaux-$pkgver.tar.gz bordeaux.initd bordeaux.confd"

build() {
	cmake \
		-DCMAKE_INSTALL_SYSCONFDIR:PATH=/etc \
		-DCMAKE_INSTALL_LOCALSTATEDIR:PATH=/var \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=/usr/lib \
		-DCMAKE_INSTALL_SBINDIR=/usr/sbin \
		-DSERVER_PREFIX_PATH=/var/lib/bordeaux \
		-DSERVER_LOGGER_PATH=/var/log/bordeaux \
		-DSERVER_CONFIG_FILE=/etc/bordeaux.conf \
		-DCMAKE_BUILD_TYPE=Release .
	make
}

check() {
	make test
}

package() {
	DESTDIR="$pkgdir" make install
	install -d -m 750 -g adm "$pkgdir"/var/log/$pkgname
	install -d -m 700 "$pkgdir"/var/lib/$pkgname
	install -D -m 700 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	install -D -m 640 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
	install -Dm644 LICENSE.md "$pkgdir"/usr/share/licenses/$pkgname/LICENSE.md
	install -Dm644 drivers/DRIVER.md "$pkgdir"/usr/share/licenses/$pkgname/DRIVER.md
	install -Dm644 README.md "$pkgdir"/usr/share/doc/$pkgname/README.md
	install -Dm644 FEATURES.md "$pkgdir"/usr/share/doc/$pkgname/FEATURES.md
}

en_voices() {
	pkgdesc="bordeaux default english voice"
	depends="bordeaux"
	amove usr/share/bordeaux/voices/en
	amove usr/lib/bordeaux/plugin_en.so
}

dev() {
	default_dev
	pkgdesc="bordeaux headers and dev utils"
	amove usr/bin/bordeauxsnd
}

coventry() {
	pkgdesc="bordeaux coventry driver"
	depends="bordeaux"
	amove usr/lib/bordeaux/driver_coventry.so
}

generic() {
	pkgdesc="bordeaux generic driver"
	depends="bordeaux"
	amove usr/lib/bordeaux/driver_generic.so
}

sha512sums="
904bb25268a08f2e8995027f7504b6e31d2a7d7cf4a350f6ee45c589a569a7b2516769e06ff6b362ced48e5a3b57757797e9e66726cb0b06dd0ad963677e5746  bordeaux-0.8.1.tar.gz
ff38a277a26a5224ab041fc6916f7ff9305f85e2d72679ae3b00084a35f80eb3d7453faa1bf2d49d306bb75747bdc1ec78bb6cc14e3d1fc627ed623142a5afa0  bordeaux.initd
c6e67fbc38c8e75ea742e6b6204c8a0406b0f9226f0e667ee72c4e51bfa8d0fd45445ba160d1e7198ce509778abe94b6a86044e2aef86c31385f69f901570a1c  bordeaux.confd
"
